home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ksettings / pluginpage.h < prev   
Encoding:
C/C++ Source or Header  |  2006-05-22  |  3.8 KB  |  121 lines

  1. /*  This file is part of the KDE project
  2.     Copyright (C) 2003 Matthias Kretz <kretz@kde.org>
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License version 2 as published by the Free Software Foundation.
  7.  
  8.     This library is distributed in the hope that it will be useful,
  9.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.     Library General Public License for more details.
  12.  
  13.     You should have received a copy of the GNU Library General Public License
  14.     along with this library; see the file COPYING.LIB.  If not, write to
  15.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.     Boston, MA 02110-1301, USA.
  17.  
  18. */
  19.  
  20. #ifndef KSETTINGS_PLUGINPAGE_H
  21. #define KSETTINGS_PLUGINPAGE_H
  22.  
  23. #include <kcmodule.h>
  24. #include <kdelibs_export.h>
  25.  
  26. class KPluginSelector;
  27.  
  28. namespace KSettings
  29. {
  30.  
  31. /**
  32.  * @ingroup settings
  33.  * @ingroup plugin
  34.  * @short Convenience KCModule for creating a plugins config page.
  35.  *
  36.  * This class makes it very easy to create a plugins configuration page to your
  37.  * program. All you need to do is create a class that is derived from
  38.  * PluginPage and add the appropriate plugin infos to the KPluginSelector.
  39.  * This is done using the pluginSelector() method:
  40.  * \code
  41.  * typedef KGenericFactory<MyAppPluginConfig, QWidget> MyAppPluginConfigFactory;
  42.  * K_EXPORT_COMPONENT_FACTORY( kcm_myapppluginconfig, MyAppPluginConfigFactory( "kcm_myapppluginconfig" ) );
  43.  *
  44.  * MyAppPluginConfig( QWidget * parent, const char *, const QStringList & args )
  45.  *     : PluginPage( MyAppPluginConfigFactory::instance(), parent, args )
  46.  * {
  47.  *     pluginSelector()->addPlugins( KGlobal::instance()->instanceName(), i18n( "General Plugins" ), "General" );
  48.  *     pluginSelector()->addPlugins( KGlobal::instance()->instanceName(), i18n( "Effects" ), "Effects" );
  49.  * }
  50.  * \endcode
  51.  *
  52.  * All that remains to be done is to create the appropriate .desktop file
  53.  * \verbatim
  54.    [Desktop Entry]
  55.    Encoding=UTF-8
  56.    Icon=plugin
  57.    Type=Service
  58.    ServiceTypes=KCModule
  59.  
  60.    X-KDE-ModuleType=Library
  61.    X-KDE-Library=myapppluginconfig
  62.    X-KDE-FactoryName=MyAppPluginConfigFactory
  63.    X-KDE-ParentApp=myapp
  64.    X-KDE-ParentComponents=myapp
  65.  
  66.    Name=Plugins
  67.    Comment=Select and configure your plugins:
  68.    \endverbatim
  69.  *
  70.  * @author Matthias Kretz <kretz@kde.org>
  71.  * @since 3.2
  72.  */
  73. class KUTILS_EXPORT PluginPage : public KCModule
  74. {
  75.     Q_OBJECT
  76.     public:
  77.         /**
  78.          * Standart KCModule constructor. Automatically creates the the
  79.          * KPluginSelector widget.
  80.          */
  81.         PluginPage( QWidget * parent = 0, const char * name = 0, const QStringList & args = QStringList() );
  82.  
  83.         /**
  84.          * Standart KCModule constructor. Automatically creates the the
  85.          * KPluginSelector widget.
  86.          */
  87.         PluginPage( KInstance * instance, QWidget * parent = 0, const QStringList & args = QStringList() );
  88.  
  89.         ~PluginPage();
  90.  
  91.         /**
  92.          * @return a reference to the KPluginSelector.
  93.          */
  94.         KPluginSelector * pluginSelector();
  95.  
  96.         /**
  97.          * Load the state of the plugins (selected or not) from the KPluginInfo
  98.          * objects. For KParts plugins everything should work automatically. For
  99.          * your own type of plugins you might need to reimplement the
  100.          * KPluginInfo::pluginLoaded() method. If that doesn't fit your needs
  101.          * you can also reimplement this method.
  102.          */
  103.         virtual void load();
  104.  
  105.         /**
  106.          * Save the state of the plugins to KConfig objects
  107.          */
  108.         virtual void save();
  109.         virtual void defaults();
  110.  
  111.     private:
  112.         class PluginPagePrivate;
  113.         PluginPagePrivate * d;
  114. };
  115.  
  116. }
  117.  
  118. // vim: sw=4 sts=4 et
  119.  
  120. #endif // KSETTINGS_PLUGINPAGE_H
  121.